package bus;

import java.util.ArrayList;

import dao.AnswersDao;
import dao.QuestionsDao;
import dto.AnswersDto;
import dto.QuestionsDto;

public class QuestionBus {

	public static ArrayList<QuestionsDto> getQuestionByQuizNo(int quizNo) {
		ArrayList<QuestionsDto> result = new ArrayList<>();
		QuestionsDao questionsDao = new QuestionsDao();
		ArrayList<QuestionsDto> allQuestions = questionsDao.getAllQuestion();
		for (QuestionsDto question : allQuestions) {
			if (question.getQuizNo() == quizNo)
				result.add(question);
		}
		return result;

	}

	public static AnswersDto getAnsersByQuestionNo(int questionNo) {
		AnswersDao answersDao = new AnswersDao();
		ArrayList<AnswersDto> allAnswers = answersDao.getAllAnswer();
		for (AnswersDto answer : allAnswers) {
			if (answer.getQuestionNo() == questionNo)
				return answer;
		}
		return null;

	}
}
